package com.example.demo.controller;

import com.example.demo.aspect.TimeRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/test")
@RestController
@Slf4j
public class TestController {

    //算数异常
    @TimeRecord
    @RequestMapping("/t1")
    public String t1(){
//        int a = 10 / 0;
        log.info("执行t1");
        return "t1";
    }
    //空指针异常
    @RequestMapping("/t2")
    public int t2(){
        log.info("执行t2");

        String aa = "aaab";
        return aa.length();
    }

    //数组越界异常
    @RequestMapping("/t3")
    public int t3(){
        int[] a = {1, 2, 3};
        int val = a[4];
        return val;
    }
}
